package com.lbmb.mdps;

import com.lbmb.mdps.commons.constant.Constant;
import com.lbmb.mdps.commons.domain.*;
import com.lbmb.mdps.settings.service.ProvinceService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.annotation.Resource;
import javax.servlet.ServletContext;
import java.util.List;

/**
 * @author 林文塨
 * @date 2022-05-23 15:30
 * description
 */

@EnableTransactionManagement
@MapperScan(basePackages = {"com.lbmb.mdps.settings.dao","com.lbmb.mdps.workbench.dao"})
@SpringBootApplication
public class MdpsApplication implements CommandLineRunner {

    @Resource
    private ServletContext servletContext;
    @Resource
    private ProvinceService provinceService;

    public static void main(String[] args) {
        SpringApplication.run(MdpsApplication.class);
    }

    @Override
    public void run(String... args) {

        /*向全局作用域中添加省市表下拉框数据*/
        List<ProvinceVo> provinceVoList = provinceService.getAllProvinceVo();
        servletContext.setAttribute(Constant.ADDRESS_DATA,provinceVoList);
    }
}
